#ifndef NIM_H_
#define NIM_H_

#include "nim-common.h"

using namespace std;

typedef struct {
	int clientSocket;
	Transmission* reciveTransmissions;
	list<Transmission*> sendTransmissions;
} clientTransmissions;

int setupClient(int &sock, int portNumber, char *hostName);
void startGame(clientTransmissions& tranmissions);
bool handleIncomingTransmission(Transmission& transmissionToHandle, clientTransmissions& tranmissions);
bool sendTransmission(clientTransmissions& transmissions);
bool receiveTransmission(clientTransmissions& transmissions);
bool handleInputFromUser(clientTransmissions& tranmissions);

inline void handleYouTurnOpcode();
void handleStatusOpcode(char *buffer);
void handleAckOpcode(char *buffer);
void handleGameTypeOpcode(char *buffer);
void handleClientStatusOpcode(char *buffer);
void handleConnectedOpcode(char *buffer);
void handleChatMessageOpcode(char *buffer);
inline void handleClientRejectedOpcode();
inline void handleIllegalMoveOpcode();
void handleGameEndOpcode(char *buffer);

void createChatMessageOpcode(clientTransmissions& tranmissions, byte dst, string& msg);
void createMoveOpcode(clientTransmissions& tranmissions, char stack, int32_t amount);
void createIllegalMoveOpcode(clientTransmissions& tranmissions);
void createQuitOpcode(int &sock);

#endif /* NIM_H_ */
